#include <windows.h>
#include <iostream.h>

DWORD WINAPI ThreadFunc(HANDLE Thread)
{
	int i;
	for(i=0;i<10;i++)
	{
		cout<< i<<"\tA new thread has created!"<<endl;
		Sleep(500);
	}
	return 0;
}

DWORD WINAPI ThreadFunc1(HANDLE Thread)
{
	int i;
	for(i=0;i<10;i++)
	{
		cout<<i<<"\tSecond new thread has created!"<<endl;
		Sleep(500);
	}
	return 0;
}

int main()
{
	HANDLE threads[2];
	DWORD dwThreadId;
	threads[0]=::CreateThread(NULL,0,ThreadFunc,NULL,0,&dwThreadId);
	threads[1]=::CreateThread(NULL,0,ThreadFunc1,NULL,0,&dwThreadId);

	//cout<< "The new thread ID is :" << dwThreadId << endl;	
//	::WaitForSingleObject(threads[0],INFINITE);
//	::WaitForSingleObject(threads[1],INFINITE);	
//	::WaitForMultipleObjects(dwThreadId, threads, FALSE, INFINITE);
	::CloseHandle(threads[0]);
	::CloseHandle(threads[1]);
//	::CloseHandle(Thread);
//	::CloseHandle(Thread1);

	return 0;
}

